/**
 * 
 *
 * 
 * 
 */
package com.east196.xfast.template.singletree;

import java.util.List;

import com.east196.xfast.config.XfastConst;
import com.east196.xfast.core.menu.config.MenuConfig;
import com.east196.xfast.model.Button;
import com.east196.xfast.model.Menu;
import com.east196.xfast.model.MetaObject;
import com.east196.xfast.model.User;
import com.jfinal.core.Controller;

/**
 * 业务模版:单表树(TreeGrid)
 * 
 * @author East196
 * 
 */
public class SingleTreeController extends Controller {

	public void list() {

		String menuCode = this.getPara(0);
		
		// 获取元数据
		Menu menu = Menu.dao.findByCode(menuCode);
		MenuConfig config = menu.getConfig();
		String objectCode = config.getObjectCode();
		MetaObject object = MetaObject.dao.getByCode(objectCode);
		if (object == null) {
			throw new RuntimeException("元对象不存在,请检查:" + objectCode);
		}

		// 根据权限获取功能按钮
		User user = this.getSessionAttr(XfastConst.USER);
		List<Button> btnList = Button.dao.queryByMenuCode(menuCode, user.getRid());

		// 是否需要显示快速查询
		setAttr("isQuery", MetaObject.dao.isExistQuery(objectCode));

		setAttr("menu", menu);
		setAttr("btnList", btnList);
		setAttr("object", object);

		render("/eova/template/singletree/list.html");
	}

}
